'use strict';
exports = module.exports = function ($scope, $rootScope, $timeout, $alert, $state, $uibModal, yxtable14, $API, $compile, $rule, throttleSubmit) {
    $scope.Rule = $rule;
    $scope.frm = {
        "workTimeBegin": '', //工作时间-开始时间
        "workTimeEnd": '', //工作时间-结束时间
    }
    var timeEndArr = [
        {id:'',name:'请选择时间'}, {id:'0',name:'0:00'}, {id:'1',name:'1:00'}, {id:'2',name:'2:00'}, {id:'3',name:'3:00'}, {id:'4',name:'4:00'}, {id:'5',name:'5:00'},
        {id:'6',name:'6:00'}, {id:'7',name:'7:00'}, {id:'8',name:'8:00'}, {id:'9',name:'9:00'}, {id:'10',name:'10:00'},
        {id:'11',name:'11:00'}, {id:'12',name:'12:00'}, {id:'13',name:'13:00'}, {id:'14',name:'14:00'}, {id:'15',name:'15:00'},
        {id:'16',name:'16:00'}, {id:'17',name:'17:00'}, {id:'18',name:'18:00'}, {id:'19',name:'19:00'}, {id:'20',name:'20:00'},
        {id:'21',name:'21:00'}, {id:'22',name:'22:00'}, {id:'23',name:'23:00'}, {id:'24',name:'24:00'}
    ];
    var timeBeginArr = angular.copy(timeEndArr);
    timeBeginArr.splice(24, 1);
    var timeArrCompare = function(begin){
        var arr = [];
        for(var i = 0, l = timeEndArr.length; i < l; i++){
            if(parseInt(timeEndArr[i].id) > parseInt(begin)) {
                arr.push(timeEndArr[i])
            }
        }
        return arr;
    }
    $scope.frm2 = {
        'workTimeBeginList': select2Config( timeBeginArr ),
        'workTimeEndList': select2Config( timeEndArr ),
        'workTimeBeginChange': function(){
            $scope.frm.workTimeEnd = '';
            $scope.frm2.workTimeEndList = select2Config( timeArrCompare($scope.frm.workTimeBegin) )
        },
    }
    $scope.submitFun = throttleSubmit(function(){
        $scope.From.submitted = true;
        if( $scope.From.$invalid ) {
            $alert.error('请检查提交的信息')
            return false;
        }
        return $scope.frm
    },function(enable, param){
        console.log('提交代码', param)
        $timeout(function(){
            enable()
        },3e3)
    });
    $scope.cancelFun = function(){
        $alert.confirm("是否取消编辑？", function(close){
            // $go('app.make.maketable1');
            close();
        })
    };
}